//
//  OrderTableView.m
//  wtshoppingcite
//
//  Created by TW on 14-12-9.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "OrderTableView.h"

@implementation OrderTableView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
    self = [super initWithFrame:frame style:style];
    if(self){
        self.backgroundView = nil;
        self.backgroundColor = [UIColor whiteColor];
        self.dataSource = self;
        self.delegate = self;
        self.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    }
    return self;
}


#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 99;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.data count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    OrderDetailCell *cell =[tableView dequeueReusableCellWithIdentifier:@"cellIdentitfer"];
    if (cell == nil) {
        cell = [[OrderDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellIdentitfer"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.delegate = self;
    

    MyOrderModel *myOrderModel = [[MyOrderModel alloc]initWithMyOrderInfo:[self.data objectAtIndex:indexPath.row]];
    
    cell.myOrderModel = myOrderModel;
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(self.eventsDelegate!= nil  && [self.eventsDelegate respondsToSelector:@selector(basetableView:didSelectRowAtIndexPath:)]){
        [self.eventsDelegate basetableView:self didSelectRowAtIndexPath:indexPath];
    }
}

-(void)cancleOrderDetailCell:(MyOrderModel*)data{
    
    if([self.myOrderDelegate respondsToSelector:@selector(cancleOrderDetailTableView:)]){
        [self.myOrderDelegate cancleOrderDetailTableView:data];
    }
    
}

-(void)payOrderDetailCell:(MyOrderModel *)data{
    if([self.myOrderDelegate respondsToSelector:@selector(payOrderDetailTableView:)]){
        [self.myOrderDelegate payOrderDetailTableView:data];
    }
}

@end
